package com.example.demo.config;

        import org.springframework.amqp.core.*;
        import org.springframework.amqp.rabbit.annotation.EnableRabbit;
        import org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistry;
        import org.springframework.context.annotation.Bean;
        import org.springframework.context.annotation.Configuration;

@Configuration
//@EnableRabbit
public class RabbitMqConfig {
    @Bean
    public Queue queue1(){
        return new Queue("test1");
    }
    @Bean
    public Queue queue2(){
        return new Queue("test2");
    }

    @Bean
    public Queue queue3(){
        return new Queue("test3");
    }
    @Bean
    public Queue queue4(){
        return new Queue("helloworld_queue");
    }
    @Bean
    public Queue queue5(){
        return new Queue("work_zs_queue");
    }
    @Bean
    public Queue directQueueA(){
        return new Queue("fanout_queue1");
    }
    @Bean
    public Queue directQueueB(){
        return new Queue("fanout_queue2");
    }
    //原来可以不用配置，默认会创建fanoutExchange，现在需要配置fanoutExchange
//    @Bean
//    public FanoutExchange fanoutExchange(){
//        return new FanoutExchange("fanout_exchange2");
//    }

    @Bean
    public Queue directQueueC(){
        return new Queue("direct_queue1");
    }
    @Bean
    public Queue directQueueD(){
        return new Queue("direct_queue2");
    }
    @Bean
    public DirectExchange directZsExchange(){
        return new DirectExchange("direct_zs_exchange");
    }
    @Bean
    public Binding binding1(){
        return BindingBuilder.bind(directQueueC()).to(directZsExchange()).with("zs_news1");
    }
    @Bean
    public Binding binding2(){
        return BindingBuilder.bind(directQueueD()).to(directZsExchange()).with("zs_news2");
    }
//    @Bean
//    public RabbitListenerEndpointRegistry rabbitListenerEndpointRegistry() {
//        return new RabbitListenerEndpointRegistry();
//    }
}
